package name.matthewgreet.example4.common; import java.io.Serializable; import name.matthewgreet.example4.common.ListCache.ListCacheConfig; /** * <P>Template for web level, session-based caching a master, record list with one slave list for editing in various web * pages. Subclasses of this, as well as defining the record types, typically set list finders and other Strategies * for record list relationships and pagination that clients don't set themselves, depending on web page workflow. * Instances are typically created as Singletons.</P> * * <DL> * <DT>KM</DT><DD>Type primary key of master records</DD> * <DT>TM</DT><DD>Type of master records</DD> * <DT>K1</DT><DD>Type primary key of slave list 1 records</DD> * <DT>T1</DT><DD>Type of slave list 1 records</DD> * </DL> * * <P>As there are a bewildering set of configuration options and client Struts actions are expected to know their * responsibilities in workflow, subclasses are a convenient Javadoc reference point for documenting this, such as * below.</P> * */ public abstract class AbstractCompositeCache_1S<KM extends Serializable,TM extends Serializable, K1 extends Serializable,T1 extends Serializable> extends AbstractCompositeCache<KM,TM> { private static final long serialVersionUID = 1722427651490036480L; private ListCache<TM,K1,T1> slaveList1; /** * Creates session-based, composite cache with a master list and 1 slave list. */ protected AbstractCompositeCache_1S() { super(); ListCacheConfig<TM,K1,T1> slaveListCacheConfig1 = getSlaveListCache1Config(); slaveList1 = new ListCache<TM,K1,T1>(slaveListCacheConfig1, getMasterListCache()); slaveList1.addListCacheListener(listCache -> {notifySlaveListCache1Changed(listCache);}); } /** * Overridden by concrete implementations to configure slave list cache 1. */ protected abstract ListCacheConfig<TM,K1,T1> getSlaveListCache1Config(); /** * Notification that the slave list cache 1 has changed. */ protected void notifySlaveListCache1Changed(ListCache<?,?,T1> listCache) { // Nothing but may be overridden. } /** * Returns cache of slave list 1. */ public ListCache<TM,K1,T1> getSlaveListCache1() { return slaveList1; } }